﻿using HS.Business.Security;
using HS.Domain.EF;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace HS.Presentation.Web.Controllers
{
    public class SubtipoController : Controller
    {
        [HttpPost]
        public JsonResult GetEntitiesByService(int? idServicio, bool? rowStatus)
        {
            if (idServicio != null)
            {
                SubtipoBusiness obj = new SubtipoBusiness();
                var objList = obj.GetEntitiesByService(idServicio, rowStatus);

                var model = JsonConvert.SerializeObject(objList, new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Ignore });
                var list = Json(JsonConvert.DeserializeObject(model, typeof(List<Subtipo>)));

                return list;
            }
            else
            {
                return null;
            }
        }
    }
}
